package com.liug.droidsmall2.study.communication;

import android.text.TextUtils;

import java.util.HashMap;

/**
 * Created by LG on 2018/9/10.
 */

public class FunctionManager {

    private static FunctionManager instance;
    private HashMap<String, Children1> mChild1List;
    private HashMap<String, Children2> mChild2List;
    private HashMap<String, Children3> mChild3List;
    private HashMap<String, Children4> mChild4List;

    public static FunctionManager getInstance() {
        if (instance == null) {
            instance = new FunctionManager();
        }
        return instance;
    }

    public FunctionManager addFunction(Children1 children1) {
        mChild1List.put("abc", children1);
        return this;
    }

    public void invokeFun(String funName) {
        if (TextUtils.isEmpty(funName))
            return;

        if (mChild1List != null) {
            Children1 children1 = mChild1List.get(funName);
            if (children1 != null) {
                children1.funtion();
            } else {
                try {
                    throw new Exception("Has no this funtion:" + funName);
                } catch (Exception e) {
                }
            }
        }


    }


}
